package org.lb.MarketingSystem.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.aspectj.weaver.NewConstructorTypeMunger;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.lb.MarketingSystem.entity.Indint;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ExcelController<E, V> {
	
	@RequestMapping(value="/export")
	public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){
		List<Indint> indints = getIndint();
		modelMap.put(NormalExcelConstants.CLASS,Indint.class);
		String fileName="订单列表";
		modelMap.put(MapExcelConstants.FILE_NAME, fileName);
		modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("用户订单列表","Indint列表"));
		modelMap.put(NormalExcelConstants.DATA_LIST, indints);
		return NormalExcelConstants.JEECG_EXCEL_VIEW;
	}
	
	private List<Indint> getIndint(){
		Indint indint1 = new Indint();
		Indint indint2 = new Indint();
		indint1.setProductId(1);
		indint1.setProductName("产品1");
		indint1.setIndintNum("GDF23414");
		indint1.setUserName("用户1");
		indint1.setBuyCount(2000);
		indint1.setStatus("已完成");
		indint1.setSubmitTime("2017-5-20");
		indint1.setFinishTime("2017-5-25");
		
		indint2.setProductId(2);
		indint2.setProductName("产品2");
		indint2.setIndintNum("dfsf23424");
		indint2.setUserName("用户1");
		indint2.setBuyCount(4000);
		indint2.setStatus("已完成");
		indint2.setSubmitTime("2017-5-20");
		indint2.setFinishTime("2017-5-25");
		
		List<Indint> Indints = new ArrayList<Indint>();
		Indints.add(indint1);
		Indints.add(indint2);
		return Indints;
	}
	
	@RequestMapping("/excel")
	public String excel(){
		return "excel";
	}
}
